<html>
<head><meta charset="utf-8"><title>Naming for token-accessor functions · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20for.20token-accessor.20functions.html">Naming for token-accessor functions</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192851848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20for%20token-accessor%20functions/near/192851848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20for.20token-accessor.20functions.html#192851848">(Apr 03 2020 at 19:16)</a>:</h4>
<p>In <code>ast</code>, we have two kinds of "is this token present" funcitons: <code>has_star(&amp;self) -&gt; bool</code> and <code>is_mutable(&amp;self) -&gt; bool</code>. </p>
<p>Should we switch to the <code>has_mut</code> variant? (presumable with adding <code>mut_token()</code> accessors as well). It seems like "has token" fits better with pure-syntax style of API than "has property"</p>



<a name="192857843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Naming%20for%20token-accessor%20functions/near/192857843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbieri <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Naming.20for.20token-accessor.20functions.html#192857843">(Apr 03 2020 at 20:10)</a>:</h4>
<p>I think the most elegant and general approach is to only have an accessor returning the token and calling is_some() on its result when a boolean is desired</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>